'use strict';
/**
 * @bussiness {商品}
 * @author {填写作者}
 * @date {创建时间}
 * **/
const Service = require('egg').Service;
class Posts extends Service {
    /**@effect {拿取主页帖子信息数据}**/
    async takeHomePosts() {
        const { app } = this;
        const res = await app.mysql.select('post')
        // select * from post
        return res
    }
    /**
     * @effect {拿取关注的帖子信息数据}
     * @params {keywords, 推荐的还是关注的}
    **/
    async takeFocusOnPost(params) { 
        const enums = {
            NO_FOCUS:"推荐",
            FOCUS_ON:"关注"
        }
        const judgeFocus ={
            IS_FOCUS:enums.FOCUS_ON,
            IS_NOT_FOCUS:enums.NO_FOCUS
        }
        const { app } = this;
        const res = await app.mysql.select('post', {
            where:{isfocus_on:params.keywords == enums.FOCUS_ON ? enums.FOCUS_ON : enums.NO_FOCUS}
        })
        return res
        console.log(res,1111111111111111111111111111111111111);
    }
    /**
    * @effect {选择帖子分类拿到信息数据}   
    * @params {category:分类, name:商品名, keyword:关键词}
    * @keywords {前端传进来参数统一名字为keywords}
   **/
    async takePostsByCate(params) {
        const  {app} = this;
        const res =await app.mysql.select('post', {
            where:{categories:params.keywords}
        })
        return res
    }
    /**
     * @effect {选择帖子拿到信息数据}   
     * @params {id，商品id}
     * @id {前端传进来参数统一名字为goods_id}
    **/
    async takeAPostsById(params) {
        const {app} = this;
        const res = await app.mysql.get("post", {post_id:params.id})
        return res
    }
}
module.exports = Posts
console.log(true=="true")